package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.AssetInfoEntity;
import com.uchiha.nova.core.model.vo.AssetInfoVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.IAssetInfoService;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 资产信息 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class AssetInfoWrapper extends BaseEntityWrapper<AssetInfoEntity, AssetInfoVO>  {
  
  IAssetInfoService assetInfoService = SpringUtil.getBean(IAssetInfoService.class);
  
	public static AssetInfoWrapper build() {
		return new AssetInfoWrapper();
 	}

	@Override
	public AssetInfoVO entityVO(AssetInfoEntity assetInfoEntity) {
		AssetInfoVO assetInfoVO = new AssetInfoVO();
		BeanUtil.copyProperties(assetInfoEntity, assetInfoVO);

		return assetInfoVO;
	}
	public List<AssetInfoVO> listVO(List<AssetInfoEntity> list) {
		List<AssetInfoVO> collect = list.stream().map(item -> {
            AssetInfoVO assetInfoVO = new AssetInfoVO();
		    BeanUtil.copyProperties(item, assetInfoVO);			
			return assetInfoVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<AssetInfoVO> pageVO(IPage<AssetInfoEntity> pages) {
		IPage<AssetInfoVO> page = pages.convert(item->{
            AssetInfoVO assetInfoVO = new AssetInfoVO();
		    BeanUtil.copyProperties(item, assetInfoVO);			
			return assetInfoVO;
		});
		return page;
	}
}
